home *** CD-ROM | disk | FTP | other *** search
/ Programming Languages Suite / ProgramD2.iso / Visual Database / Visual BASIC 5.0 (Ent. Edition) / Vb5ent Extractor.EXE / VB / SAMPLES / PGUIDE / MDI / NOTEPAD.FRM (.txt) < prev   
Encoding:
Visual Basic Form  |  1996-11-12  |  12.9 KB  |  386 lines

  1. VERSION 5.00
  2. Begin VB.Form frmNotePad 
  3.    Caption         =   "Untitled"
  4.    ClientHeight    =   3990
  5.    ClientLeft      =   1515
  6.    ClientTop       =   3315
  7.    ClientWidth     =   5670
  8.    BeginProperty Font 
  9.       Name            =   "MS Sans Serif"
  10.       Size            =   8.25
  11.       Charset         =   0
  12.       Weight          =   700
  13.       Underline       =   0   'False
  14.       Italic          =   0   'False
  15.       Strikethrough   =   0   'False
  16.    EndProperty
  17.    Height          =   4395
  18.    Left            =   1455
  19.    LinkTopic       =   "Form1"
  20.    MDIChild        =   -1  'True
  21.    ScaleHeight     =   3990
  22.    ScaleMode       =   0  'User
  23.    ScaleWidth      =   101.07
  24.    Top             =   2970
  25.    Width           =   5790
  26.    Begin VB.TextBox Text1 
  27.       Height          =   3975
  28.       HideSelection   =   0   'False
  29.       Left            =   0
  30.       MultiLine       =   -1  'True
  31.       ScrollBars      =   2  'Vertical
  32.       TabIndex        =   0
  33.       Top             =   0
  34.       Width           =   5655
  35.    End
  36.    Begin VB.Menu mnuFile 
  37.       Caption         =   "&File"
  38.       Begin VB.Menu mnuFileNew 
  39.          Caption         =   "&New"
  40.       End
  41.       Begin VB.Menu mnuFileOpen 
  42.          Caption         =   "&Open..."
  43.       End
  44.       Begin VB.Menu mnuFileClose 
  45.          Caption         =   "&Close"
  46.       End
  47.       Begin VB.Menu mnuFileSave 
  48.          Caption         =   "&Save"
  49.       End
  50.       Begin VB.Menu mnuFileSaveAs 
  51.          Caption         =   "Save &As..."
  52.       End
  53.       Begin VB.Menu mnuFSep 
  54.          Caption         =   "-"
  55.       End
  56.       Begin VB.Menu mnuFileExit 
  57.          Caption         =   "E&xit"
  58.       End
  59.       Begin VB.Menu mnuRecentFile 
  60.          Caption         =   "-"
  61.          Index           =   0
  62.          Visible         =   0   'False
  63.       End
  64.       Begin VB.Menu mnuRecentFile 
  65.          Caption         =   "RecentFile1"
  66.          Index           =   1
  67.          Visible         =   0   'False
  68.       End
  69.       Begin VB.Menu mnuRecentFile 
  70.          Caption         =   "RecentFile2"
  71.          Index           =   2
  72.          Visible         =   0   'False
  73.       End
  74.       Begin VB.Menu mnuRecentFile 
  75.          Caption         =   "RecentFile3"
  76.          Index           =   3
  77.          Visible         =   0   'False
  78.       End
  79.       Begin VB.Menu mnuRecentFile 
  80.          Caption         =   "RecentFile4"
  81.          Index           =   4
  82.          Visible         =   0   'False
  83.       End
  84.       Begin VB.Menu mnuRecentFile 
  85.          Caption         =   "RecentFile5"
  86.          Index           =   5
  87.          Visible         =   0   'False
  88.       End
  89.    End
  90.    Begin VB.Menu mnuEdit 
  91.       Caption         =   "&Edit"
  92.       Begin VB.Menu mnuEditCut 
  93.          Caption         =   "Cu&t"
  94.          Shortcut        =   ^X
  95.       End
  96.       Begin VB.Menu mnuEditCopy 
  97.          Caption         =   "&Copy"
  98.          Shortcut        =   ^C
  99.       End
  100.       Begin VB.Menu mnuEditPaste 
  101.          Caption         =   "&Paste"
  102.          Shortcut        =   ^V
  103.       End
  104.       Begin VB.Menu mnuEditDelete 
  105.          Caption         =   "De&lete"
  106.          Shortcut        =   {DEL}
  107.       End
  108.       Begin VB.Menu mnuESep1 
  109.          Caption         =   "-"
  110.       End
  111.       Begin VB.Menu mnuEditSelectAll 
  112.          Caption         =   "Select &All"
  113.       End
  114.       Begin VB.Menu mnuEditTime 
  115.          Caption         =   "Time/&Date"
  116.       End
  117.    End
  118.    Begin VB.Menu mnuSearch 
  119.       Caption         =   "&Search"
  120.       Begin VB.Menu mnuSearchFind 
  121.          Caption         =   "&Find"
  122.       End
  123.       Begin VB.Menu mnuSearchFindNext 
  124.          Caption         =   "Find &Next"
  125.          Shortcut        =   {F3}
  126.       End
  127.    End
  128.    Begin VB.Menu mnuOptions 
  129.       Caption         =   "&Options"
  130.       Begin VB.Menu mnuOptionsToolbar 
  131.          Caption         =   "&Toolbar"
  132.       End
  133.       Begin VB.Menu mnuFont 
  134.          Caption         =   "&Font"
  135.          Begin VB.Menu mnuFontName 
  136.             Caption         =   "FontName"
  137.             Index           =   0
  138.          End
  139.       End
  140.    End
  141.    Begin VB.Menu mnuWindow 
  142.       Caption         =   "&Window"
  143.       WindowList      =   -1  'True
  144.       Begin VB.Menu mnuWindowCascade 
  145.          Caption         =   "&Cascade"
  146.       End
  147.       Begin VB.Menu mnuWindowTile 
  148.          Caption         =   "&Tile"
  149.       End
  150.       Begin VB.Menu mnuWindowArrange 
  151.          Caption         =   "&Arrange Icons"
  152.       End
  153.    End
  154. Attribute VB_Name = "frmNotePad"
  155. Attribute VB_Base = "0{B61445D4-CA75-11CF-84BA-00AA00C007F0}"
  156. Attribute VB_Creatable = False
  157. Attribute VB_TemplateDerived = False
  158. Attribute VB_PredeclaredId = True
  159. Attribute VB_Exposed = False
  160. Attribute VB_Customizable = False
  161. '*** Child form for the MDI Notepad sample application  ***
  162. '**********************************************************
  163. Option Explicit
  164. Private Sub Form_Load()
  165.     Dim i As Integer        ' Counter variable.
  166.     ' Assign the name of the first font to a font
  167.     ' menu entry, then loop through the fonts
  168.     ' collection, adding them to the menu
  169.     mnuFontName(0).Caption = Screen.Fonts(0)
  170.     For i = 1 To Screen.FontCount - 1
  171.         Load mnuFontName(i)
  172.         mnuFontName(0).Caption = Screen.Fonts(i)
  173.     Next
  174. End Sub
  175. Private Sub Form_QueryUnload(Cancel As Integer, UnloadMode As Integer)
  176.     Dim strMsg As String
  177.     Dim strFilename As String
  178.     Dim intResponse As Integer
  179.     ' Check to see if the text has been changed.
  180.     If FState(Me.Tag).Dirty Then
  181.         strFilename = Me.Caption
  182.         strMsg = "The text in [" & strFilename & "] has changed."
  183.         strMsg = strMsg & vbCrLf
  184.         strMsg = strMsg & "Do you want to save the changes?"
  185.         intResponse = MsgBox(strMsg, 51, frmMDI.Caption)
  186.         Select Case intResponse
  187.             Case 6      ' User chose Yes.
  188.                 If Left(Me.Caption, 8) = "Untitled" Then
  189.                     ' The file hasn't been saved yet.
  190.                     strFilename = "untitled.txt"
  191.                     ' Get the strFilename, and then call the save procedure, GetstrFilename.
  192.                     strFilename = GetFileName(strFilename)
  193.                 Else
  194.                     ' The form's Caption contains the name of the open file.
  195.                     strFilename = Me.Caption
  196.                 End If
  197.                 ' Call the save procedure. If strFilename = Empty, then
  198.                 ' the user chose Cancel in the Save As dialog box; otherwise,
  199.                 ' save the file.
  200.                 If strFilename <> "" Then
  201.                     SaveFileAs strFilename
  202.                 End If
  203.             Case 7      ' User chose No. Unload the file.
  204.                 Cancel = False
  205.             Case 2      ' User chose Cancel. Cancel the unload.
  206.                 Cancel = True
  207.         End Select
  208.     End If
  209. End Sub
  210. Private Sub Form_Resize()
  211.     ' Expand text box to fill the current child form's internal area.
  212.     Text1.Height = ScaleHeight
  213.     Text1.Width = ScaleWidth
  214. End Sub
  215. Private Sub Form_Unload(Cancel As Integer)
  216.     ' Show the current form instance as deleted
  217.     FState(Me.Tag).Deleted = True
  218.     ' Hide the toolbar edit buttons if no notepad windows exist.
  219.     If Not AnyPadsLeft() Then
  220.         frmMDI.imgCutButton.Visible = False
  221.         frmMDI.imgCopyButton.Visible = False
  222.         frmMDI.imgPasteButton.Visible = False
  223.         ' Toggle the public tool state variable
  224.         gToolsHidden = True
  225.         ' Call the recent file list procedure
  226.         GetRecentFiles
  227.     End If
  228. End Sub
  229. Private Sub mnuEditCopy_Click()
  230.     ' Call the copy procedure
  231.     EditCopyProc
  232. End Sub
  233. Private Sub mnuEditCut_Click()
  234.     ' Call the cut procedure
  235.     EditCutProc
  236. End Sub
  237. Private Sub mnuEditDelete_Click()
  238.     ' If the mouse pointer is not at the end of the notepad...
  239.     If Screen.ActiveControl.SelStart <> Len(Screen.ActiveControl.Text) Then
  240.         ' If nothing is selected, extend the selection by one.
  241.         If Screen.ActiveControl.SelLength = 0 Then
  242.             Screen.ActiveControl.SelLength = 1
  243.             ' If the mouse pointer is on a blank line, extend the selection by two.
  244.             If Asc(Screen.ActiveControl.SelText) = 13 Then
  245.                 Screen.ActiveControl.SelLength = 2
  246.             End If
  247.         End If
  248.         ' Delete the selected text.
  249.         Screen.ActiveControl.SelText = ""
  250.     End If
  251. End Sub
  252. Private Sub mnuEditPaste_Click()
  253.     ' Call the paste procedure.
  254.     EditPasteProc
  255. End Sub
  256. Private Sub mnuEditSelectAll_Click()
  257.     ' Use SelStart & SelLength to select the text.
  258.     frmMDI.ActiveForm.Text1.SelStart = 0
  259.     frmMDI.ActiveForm.Text1.SelLength = Len(frmMDI.ActiveForm.Text1.Text)
  260. End Sub
  261. Private Sub mnuEditTime_Click()
  262.     ' Insert the current time and date.
  263.     Text1.SelText = Now
  264. End Sub
  265. Private Sub mnuFileClose_Click()
  266.     ' Unload this form.
  267.     Unload Me
  268. End Sub
  269. Private Sub mnuFileExit_Click()
  270.     ' Unloading the MDI form invokes the QueryUnload event
  271.     ' for each child form, and then the MDI form.
  272.     ' Setting the Cancel argument to True in any of the
  273.     ' QueryUnload events cancels the unload.
  274.     Unload frmMDI
  275. End Sub
  276. Private Sub mnuFileNew_Click()
  277.     ' Call the new form procedure
  278.     FileNew
  279. End Sub
  280. Private Sub mnuFontName_Click(index As Integer)
  281.     ' Assign the selected font to the textbox fontname property.
  282.     Text1.FontName = mnuFontName(index).Caption
  283. End Sub
  284. Private Sub mnuFileOpen_Click()
  285.     ' Call the file open procedure.
  286.     FileOpenProc
  287. End Sub
  288. Private Sub mnuFileSave_Click()
  289.     Dim strFilename As String
  290.     If Left(Me.Caption, 8) = "Untitled" Then
  291.         ' The file hasn't been saved yet.
  292.         ' Get the filename, and then call the save procedure, GetFileName.
  293.         strFilename = GetFileName(strFilename)
  294.     Else
  295.         ' The form's Caption contains the name of the open file.
  296.         strFilename = Me.Caption
  297.     End If
  298.     ' Call the save procedure. If Filename = Empty, then
  299.     ' the user chose Cancel in the Save As dialog box; otherwise,
  300.     ' save the file.
  301.     If strFilename <> "" Then
  302.         SaveFileAs strFilename
  303.     End If
  304. End Sub
  305. Private Sub mnuFileSaveAs_Click()
  306.     Dim strSaveFileName As String
  307.     Dim strDefaultName As String
  308.     ' Assign the form caption to the variable.
  309.     strDefaultName = Me.Caption
  310.     If Left(Me.Caption, 8) = "Untitled" Then
  311.         ' The file hasn't been saved yet.
  312.         ' Get the filename, and then call the save procedure, strSaveFileName.
  313.         
  314.         strSaveFileName = GetFileName("Untitled.txt")
  315.         If strSaveFileName <> "" Then SaveFileAs (strSaveFileName)
  316.         ' Update the list of recently opened files in the File menu control array.
  317.         UpdateFileMenu (strSaveFileName)
  318.     Else
  319.         ' The form's Caption contains the name of the open file.
  320.         
  321.         strSaveFileName = GetFileName(strDefaultName)
  322.         If strSaveFileName <> "" Then SaveFileAs (strSaveFileName)
  323.         ' Update the list of recently opened files in the File menu control array.
  324.         UpdateFileMenu (strSaveFileName)
  325.     End If
  326. End Sub
  327. Private Sub mnuOptions_Click()
  328.     ' Toggle the Checked property to match the .Visible property.
  329.     mnuOptionsToolbar.Checked = frmMDI.picToolbar.Visible
  330. End Sub
  331. Private Sub mnuOptionsToolbar_Click()
  332.     ' Call the toolbar procedure, passing a reference
  333.     ' to this form instance.
  334.     OptionsToolbarProc Me
  335. End Sub
  336. Private Sub mnuRecentFile_Click(index As Integer)
  337.     ' Call the file open procedure, passing a
  338.     ' reference to the selected file name
  339.     OpenFile (mnuRecentFile(index).Caption)
  340.     ' Update the list of recently opened files in the File menu control array.
  341.     GetRecentFiles
  342. End Sub
  343. Private Sub mnuSearchFind_Click()
  344.     ' If there is text in the textbox, assign it to
  345.     ' the textbox on the Find form, otherwise assign
  346.     ' the last findtext value.
  347.     If Me.Text1.SelText <> "" Then
  348.         frmFind.Text1.Text = Me.Text1.SelText
  349.     Else
  350.         frmFind.Text1.Text = gFindString
  351.     End If
  352.     ' Set the public variable to start at the beginning.
  353.     gFirstTime = True
  354.     ' Set the case checkbox to match the public variable
  355.     If (gFindCase) Then
  356.         frmFind.chkCase = 1
  357.     End If
  358.     ' Display the Find form.
  359.     frmFind.Show vbModal
  360. End Sub
  361. Private Sub mnuSearchFindNext_Click()
  362.     ' If the public variable isn't empty, call the
  363.     ' find procedure, otherwise call the find menu
  364.     If Len(gFindString) > 0 Then
  365.         FindIt
  366.     Else
  367.         mnuSearchFind_Click
  368.     End If
  369. End Sub
  370. Private Sub mnuWindowArrange_Click()
  371.     ' Arrange the icons for any minimzied child forms.
  372.     frmMDI.Arrange vbArrangeIcons
  373. End Sub
  374. Private Sub mnuWindowCascade_Click()
  375.     ' Cascade the child forms.
  376.     frmMDI.Arrange vbCascade
  377. End Sub
  378. Private Sub mnuWindowTile_Click()
  379.     ' Tile the child forms.
  380.     frmMDI.Arrange vbTileHorizontal
  381. End Sub
  382. Private Sub Text1_Change()
  383.     ' Set the public variable to show that text has changed.
  384.     FState(Me.Tag).Dirty = True
  385. End Sub
  386.